#include "SString.h"

SStringSp SString::Parse(string s)
{
	trim(s);

	// Check syntax 
	//   - "..."

	regex reg("\".*\"$");

	if ( !regex_match(s, reg))
	{
		throw SParseException("Syntax error: " + s + " is not a SString literal.");
	}

	return SString::Create( s.substr(1, s.size()-2) );
}

std::string SString::ToString( string format )
{
	if ( format == "n" )
	{
		return value;
	}

	return "\"" + value + "\"";
}

SStringSp SString::Create( string value )
{
	return SStringSp(new SString(value));
}
